{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Pandas method"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import os\n",
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [],
   "source": [
    "f_name = os.path.join(\"./data/\", \"iris.data\")\n",
    "df = pd.read_csv(f_name, names=[\"sepal length\", \"sepal width\", \"petal length\", \"petal width\", \"class\"])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1.1 Map"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>sepal length</th>\n",
       "      <th>sepal width</th>\n",
       "      <th>petal length</th>\n",
       "      <th>petal width</th>\n",
       "      <th>class</th>\n",
       "      <th>short-class</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5.1</td>\n",
       "      <td>3.5</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>4.9</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>4.7</td>\n",
       "      <td>3.2</td>\n",
       "      <td>1.3</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4.6</td>\n",
       "      <td>3.1</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5.0</td>\n",
       "      <td>3.6</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>5.4</td>\n",
       "      <td>3.9</td>\n",
       "      <td>1.7</td>\n",
       "      <td>0.4</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>4.6</td>\n",
       "      <td>3.4</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.3</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>5.0</td>\n",
       "      <td>3.4</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>4.4</td>\n",
       "      <td>2.9</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>4.9</td>\n",
       "      <td>3.1</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.1</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>5.4</td>\n",
       "      <td>3.7</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>4.8</td>\n",
       "      <td>3.4</td>\n",
       "      <td>1.6</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>4.8</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.1</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>4.3</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.1</td>\n",
       "      <td>0.1</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>5.8</td>\n",
       "      <td>4.0</td>\n",
       "      <td>1.2</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>5.7</td>\n",
       "      <td>4.4</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.4</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>5.4</td>\n",
       "      <td>3.9</td>\n",
       "      <td>1.3</td>\n",
       "      <td>0.4</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>5.1</td>\n",
       "      <td>3.5</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.3</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>5.7</td>\n",
       "      <td>3.8</td>\n",
       "      <td>1.7</td>\n",
       "      <td>0.3</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>5.1</td>\n",
       "      <td>3.8</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.3</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>5.4</td>\n",
       "      <td>3.4</td>\n",
       "      <td>1.7</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>5.1</td>\n",
       "      <td>3.7</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.4</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>4.6</td>\n",
       "      <td>3.6</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>5.1</td>\n",
       "      <td>3.3</td>\n",
       "      <td>1.7</td>\n",
       "      <td>0.5</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>4.8</td>\n",
       "      <td>3.4</td>\n",
       "      <td>1.9</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>5.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.6</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>5.0</td>\n",
       "      <td>3.4</td>\n",
       "      <td>1.6</td>\n",
       "      <td>0.4</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>5.2</td>\n",
       "      <td>3.5</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>5.2</td>\n",
       "      <td>3.4</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>4.7</td>\n",
       "      <td>3.2</td>\n",
       "      <td>1.6</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>120</th>\n",
       "      <td>6.9</td>\n",
       "      <td>3.2</td>\n",
       "      <td>5.7</td>\n",
       "      <td>2.3</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>121</th>\n",
       "      <td>5.6</td>\n",
       "      <td>2.8</td>\n",
       "      <td>4.9</td>\n",
       "      <td>2.0</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>122</th>\n",
       "      <td>7.7</td>\n",
       "      <td>2.8</td>\n",
       "      <td>6.7</td>\n",
       "      <td>2.0</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>123</th>\n",
       "      <td>6.3</td>\n",
       "      <td>2.7</td>\n",
       "      <td>4.9</td>\n",
       "      <td>1.8</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>124</th>\n",
       "      <td>6.7</td>\n",
       "      <td>3.3</td>\n",
       "      <td>5.7</td>\n",
       "      <td>2.1</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>125</th>\n",
       "      <td>7.2</td>\n",
       "      <td>3.2</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1.8</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>126</th>\n",
       "      <td>6.2</td>\n",
       "      <td>2.8</td>\n",
       "      <td>4.8</td>\n",
       "      <td>1.8</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>127</th>\n",
       "      <td>6.1</td>\n",
       "      <td>3.0</td>\n",
       "      <td>4.9</td>\n",
       "      <td>1.8</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>128</th>\n",
       "      <td>6.4</td>\n",
       "      <td>2.8</td>\n",
       "      <td>5.6</td>\n",
       "      <td>2.1</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>129</th>\n",
       "      <td>7.2</td>\n",
       "      <td>3.0</td>\n",
       "      <td>5.8</td>\n",
       "      <td>1.6</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>130</th>\n",
       "      <td>7.4</td>\n",
       "      <td>2.8</td>\n",
       "      <td>6.1</td>\n",
       "      <td>1.9</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>131</th>\n",
       "      <td>7.9</td>\n",
       "      <td>3.8</td>\n",
       "      <td>6.4</td>\n",
       "      <td>2.0</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>132</th>\n",
       "      <td>6.4</td>\n",
       "      <td>2.8</td>\n",
       "      <td>5.6</td>\n",
       "      <td>2.2</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>133</th>\n",
       "      <td>6.3</td>\n",
       "      <td>2.8</td>\n",
       "      <td>5.1</td>\n",
       "      <td>1.5</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>134</th>\n",
       "      <td>6.1</td>\n",
       "      <td>2.6</td>\n",
       "      <td>5.6</td>\n",
       "      <td>1.4</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>135</th>\n",
       "      <td>7.7</td>\n",
       "      <td>3.0</td>\n",
       "      <td>6.1</td>\n",
       "      <td>2.3</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>136</th>\n",
       "      <td>6.3</td>\n",
       "      <td>3.4</td>\n",
       "      <td>5.6</td>\n",
       "      <td>2.4</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>137</th>\n",
       "      <td>6.4</td>\n",
       "      <td>3.1</td>\n",
       "      <td>5.5</td>\n",
       "      <td>1.8</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>138</th>\n",
       "      <td>6.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>4.8</td>\n",
       "      <td>1.8</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>139</th>\n",
       "      <td>6.9</td>\n",
       "      <td>3.1</td>\n",
       "      <td>5.4</td>\n",
       "      <td>2.1</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>140</th>\n",
       "      <td>6.7</td>\n",
       "      <td>3.1</td>\n",
       "      <td>5.6</td>\n",
       "      <td>2.4</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>141</th>\n",
       "      <td>6.9</td>\n",
       "      <td>3.1</td>\n",
       "      <td>5.1</td>\n",
       "      <td>2.3</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>142</th>\n",
       "      <td>5.8</td>\n",
       "      <td>2.7</td>\n",
       "      <td>5.1</td>\n",
       "      <td>1.9</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>143</th>\n",
       "      <td>6.8</td>\n",
       "      <td>3.2</td>\n",
       "      <td>5.9</td>\n",
       "      <td>2.3</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>144</th>\n",
       "      <td>6.7</td>\n",
       "      <td>3.3</td>\n",
       "      <td>5.7</td>\n",
       "      <td>2.5</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>145</th>\n",
       "      <td>6.7</td>\n",
       "      <td>3.0</td>\n",
       "      <td>5.2</td>\n",
       "      <td>2.3</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146</th>\n",
       "      <td>6.3</td>\n",
       "      <td>2.5</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1.9</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>147</th>\n",
       "      <td>6.5</td>\n",
       "      <td>3.0</td>\n",
       "      <td>5.2</td>\n",
       "      <td>2.0</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>148</th>\n",
       "      <td>6.2</td>\n",
       "      <td>3.4</td>\n",
       "      <td>5.4</td>\n",
       "      <td>2.3</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>149</th>\n",
       "      <td>5.9</td>\n",
       "      <td>3.0</td>\n",
       "      <td>5.1</td>\n",
       "      <td>1.8</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>150 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     sepal length  sepal width  petal length  petal width           class  \\\n",
       "0             5.1          3.5           1.4          0.2     Iris-setosa   \n",
       "1             4.9          3.0           1.4          0.2     Iris-setosa   \n",
       "2             4.7          3.2           1.3          0.2     Iris-setosa   \n",
       "3             4.6          3.1           1.5          0.2     Iris-setosa   \n",
       "4             5.0          3.6           1.4          0.2     Iris-setosa   \n",
       "5             5.4          3.9           1.7          0.4     Iris-setosa   \n",
       "6             4.6          3.4           1.4          0.3     Iris-setosa   \n",
       "7             5.0          3.4           1.5          0.2     Iris-setosa   \n",
       "8             4.4          2.9           1.4          0.2     Iris-setosa   \n",
       "9             4.9          3.1           1.5          0.1     Iris-setosa   \n",
       "10            5.4          3.7           1.5          0.2     Iris-setosa   \n",
       "11            4.8          3.4           1.6          0.2     Iris-setosa   \n",
       "12            4.8          3.0           1.4          0.1     Iris-setosa   \n",
       "13            4.3          3.0           1.1          0.1     Iris-setosa   \n",
       "14            5.8          4.0           1.2          0.2     Iris-setosa   \n",
       "15            5.7          4.4           1.5          0.4     Iris-setosa   \n",
       "16            5.4          3.9           1.3          0.4     Iris-setosa   \n",
       "17            5.1          3.5           1.4          0.3     Iris-setosa   \n",
       "18            5.7          3.8           1.7          0.3     Iris-setosa   \n",
       "19            5.1          3.8           1.5          0.3     Iris-setosa   \n",
       "20            5.4          3.4           1.7          0.2     Iris-setosa   \n",
       "21            5.1          3.7           1.5          0.4     Iris-setosa   \n",
       "22            4.6          3.6           1.0          0.2     Iris-setosa   \n",
       "23            5.1          3.3           1.7          0.5     Iris-setosa   \n",
       "24            4.8          3.4           1.9          0.2     Iris-setosa   \n",
       "25            5.0          3.0           1.6          0.2     Iris-setosa   \n",
       "26            5.0          3.4           1.6          0.4     Iris-setosa   \n",
       "27            5.2          3.5           1.5          0.2     Iris-setosa   \n",
       "28            5.2          3.4           1.4          0.2     Iris-setosa   \n",
       "29            4.7          3.2           1.6          0.2     Iris-setosa   \n",
       "..            ...          ...           ...          ...             ...   \n",
       "120           6.9          3.2           5.7          2.3  Iris-virginica   \n",
       "121           5.6          2.8           4.9          2.0  Iris-virginica   \n",
       "122           7.7          2.8           6.7          2.0  Iris-virginica   \n",
       "123           6.3          2.7           4.9          1.8  Iris-virginica   \n",
       "124           6.7          3.3           5.7          2.1  Iris-virginica   \n",
       "125           7.2          3.2           6.0          1.8  Iris-virginica   \n",
       "126           6.2          2.8           4.8          1.8  Iris-virginica   \n",
       "127           6.1          3.0           4.9          1.8  Iris-virginica   \n",
       "128           6.4          2.8           5.6          2.1  Iris-virginica   \n",
       "129           7.2          3.0           5.8          1.6  Iris-virginica   \n",
       "130           7.4          2.8           6.1          1.9  Iris-virginica   \n",
       "131           7.9          3.8           6.4          2.0  Iris-virginica   \n",
       "132           6.4          2.8           5.6          2.2  Iris-virginica   \n",
       "133           6.3          2.8           5.1          1.5  Iris-virginica   \n",
       "134           6.1          2.6           5.6          1.4  Iris-virginica   \n",
       "135           7.7          3.0           6.1          2.3  Iris-virginica   \n",
       "136           6.3          3.4           5.6          2.4  Iris-virginica   \n",
       "137           6.4          3.1           5.5          1.8  Iris-virginica   \n",
       "138           6.0          3.0           4.8          1.8  Iris-virginica   \n",
       "139           6.9          3.1           5.4          2.1  Iris-virginica   \n",
       "140           6.7          3.1           5.6          2.4  Iris-virginica   \n",
       "141           6.9          3.1           5.1          2.3  Iris-virginica   \n",
       "142           5.8          2.7           5.1          1.9  Iris-virginica   \n",
       "143           6.8          3.2           5.9          2.3  Iris-virginica   \n",
       "144           6.7          3.3           5.7          2.5  Iris-virginica   \n",
       "145           6.7          3.0           5.2          2.3  Iris-virginica   \n",
       "146           6.3          2.5           5.0          1.9  Iris-virginica   \n",
       "147           6.5          3.0           5.2          2.0  Iris-virginica   \n",
       "148           6.2          3.4           5.4          2.3  Iris-virginica   \n",
       "149           5.9          3.0           5.1          1.8  Iris-virginica   \n",
       "\n",
       "    short-class  \n",
       "0           SET  \n",
       "1           SET  \n",
       "2           SET  \n",
       "3           SET  \n",
       "4           SET  \n",
       "5           SET  \n",
       "6           SET  \n",
       "7           SET  \n",
       "8           SET  \n",
       "9           SET  \n",
       "10          SET  \n",
       "11          SET  \n",
       "12          SET  \n",
       "13          SET  \n",
       "14          SET  \n",
       "15          SET  \n",
       "16          SET  \n",
       "17          SET  \n",
       "18          SET  \n",
       "19          SET  \n",
       "20          SET  \n",
       "21          SET  \n",
       "22          SET  \n",
       "23          SET  \n",
       "24          SET  \n",
       "25          SET  \n",
       "26          SET  \n",
       "27          SET  \n",
       "28          SET  \n",
       "29          SET  \n",
       "..          ...  \n",
       "120         VIR  \n",
       "121         VIR  \n",
       "122         VIR  \n",
       "123         VIR  \n",
       "124         VIR  \n",
       "125         VIR  \n",
       "126         VIR  \n",
       "127         VIR  \n",
       "128         VIR  \n",
       "129         VIR  \n",
       "130         VIR  \n",
       "131         VIR  \n",
       "132         VIR  \n",
       "133         VIR  \n",
       "134         VIR  \n",
       "135         VIR  \n",
       "136         VIR  \n",
       "137         VIR  \n",
       "138         VIR  \n",
       "139         VIR  \n",
       "140         VIR  \n",
       "141         VIR  \n",
       "142         VIR  \n",
       "143         VIR  \n",
       "144         VIR  \n",
       "145         VIR  \n",
       "146         VIR  \n",
       "147         VIR  \n",
       "148         VIR  \n",
       "149         VIR  \n",
       "\n",
       "[150 rows x 6 columns]"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"short-class\"] = df[\"class\"].map({\"Iris-setosa\": \"SET\", \"Iris-virginica\": \"VIR\", \"Iris-versicolor\": \"VER\"}); df\n",
    "# df[\"class\"] = df[\"class\"].map({\"Iris-setosa\": \"SET\", \"Iris-virginica\": \"VIR\", \"Iris-versicolor\": \"VER\"}); df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1.2 Apply"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>sepal length</th>\n",
       "      <th>sepal width</th>\n",
       "      <th>petal length</th>\n",
       "      <th>petal width</th>\n",
       "      <th>class</th>\n",
       "      <th>short-class</th>\n",
       "      <th>wide petal</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5.1</td>\n",
       "      <td>3.5</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>4.9</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>4.7</td>\n",
       "      <td>3.2</td>\n",
       "      <td>1.3</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4.6</td>\n",
       "      <td>3.1</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5.0</td>\n",
       "      <td>3.6</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>5.4</td>\n",
       "      <td>3.9</td>\n",
       "      <td>1.7</td>\n",
       "      <td>0.4</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>4.6</td>\n",
       "      <td>3.4</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.3</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>5.0</td>\n",
       "      <td>3.4</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>4.4</td>\n",
       "      <td>2.9</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>4.9</td>\n",
       "      <td>3.1</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.1</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>5.4</td>\n",
       "      <td>3.7</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>4.8</td>\n",
       "      <td>3.4</td>\n",
       "      <td>1.6</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>4.8</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.1</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>4.3</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.1</td>\n",
       "      <td>0.1</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>5.8</td>\n",
       "      <td>4.0</td>\n",
       "      <td>1.2</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>5.7</td>\n",
       "      <td>4.4</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.4</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>5.4</td>\n",
       "      <td>3.9</td>\n",
       "      <td>1.3</td>\n",
       "      <td>0.4</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>5.1</td>\n",
       "      <td>3.5</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.3</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>5.7</td>\n",
       "      <td>3.8</td>\n",
       "      <td>1.7</td>\n",
       "      <td>0.3</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>5.1</td>\n",
       "      <td>3.8</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.3</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>5.4</td>\n",
       "      <td>3.4</td>\n",
       "      <td>1.7</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>5.1</td>\n",
       "      <td>3.7</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.4</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>4.6</td>\n",
       "      <td>3.6</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>5.1</td>\n",
       "      <td>3.3</td>\n",
       "      <td>1.7</td>\n",
       "      <td>0.5</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>4.8</td>\n",
       "      <td>3.4</td>\n",
       "      <td>1.9</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>5.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.6</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>5.0</td>\n",
       "      <td>3.4</td>\n",
       "      <td>1.6</td>\n",
       "      <td>0.4</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>5.2</td>\n",
       "      <td>3.5</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>5.2</td>\n",
       "      <td>3.4</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>4.7</td>\n",
       "      <td>3.2</td>\n",
       "      <td>1.6</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>120</th>\n",
       "      <td>6.9</td>\n",
       "      <td>3.2</td>\n",
       "      <td>5.7</td>\n",
       "      <td>2.3</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>121</th>\n",
       "      <td>5.6</td>\n",
       "      <td>2.8</td>\n",
       "      <td>4.9</td>\n",
       "      <td>2.0</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>122</th>\n",
       "      <td>7.7</td>\n",
       "      <td>2.8</td>\n",
       "      <td>6.7</td>\n",
       "      <td>2.0</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>123</th>\n",
       "      <td>6.3</td>\n",
       "      <td>2.7</td>\n",
       "      <td>4.9</td>\n",
       "      <td>1.8</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>124</th>\n",
       "      <td>6.7</td>\n",
       "      <td>3.3</td>\n",
       "      <td>5.7</td>\n",
       "      <td>2.1</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>125</th>\n",
       "      <td>7.2</td>\n",
       "      <td>3.2</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1.8</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>126</th>\n",
       "      <td>6.2</td>\n",
       "      <td>2.8</td>\n",
       "      <td>4.8</td>\n",
       "      <td>1.8</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>127</th>\n",
       "      <td>6.1</td>\n",
       "      <td>3.0</td>\n",
       "      <td>4.9</td>\n",
       "      <td>1.8</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>128</th>\n",
       "      <td>6.4</td>\n",
       "      <td>2.8</td>\n",
       "      <td>5.6</td>\n",
       "      <td>2.1</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>129</th>\n",
       "      <td>7.2</td>\n",
       "      <td>3.0</td>\n",
       "      <td>5.8</td>\n",
       "      <td>1.6</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>130</th>\n",
       "      <td>7.4</td>\n",
       "      <td>2.8</td>\n",
       "      <td>6.1</td>\n",
       "      <td>1.9</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>131</th>\n",
       "      <td>7.9</td>\n",
       "      <td>3.8</td>\n",
       "      <td>6.4</td>\n",
       "      <td>2.0</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>132</th>\n",
       "      <td>6.4</td>\n",
       "      <td>2.8</td>\n",
       "      <td>5.6</td>\n",
       "      <td>2.2</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>133</th>\n",
       "      <td>6.3</td>\n",
       "      <td>2.8</td>\n",
       "      <td>5.1</td>\n",
       "      <td>1.5</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>134</th>\n",
       "      <td>6.1</td>\n",
       "      <td>2.6</td>\n",
       "      <td>5.6</td>\n",
       "      <td>1.4</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>135</th>\n",
       "      <td>7.7</td>\n",
       "      <td>3.0</td>\n",
       "      <td>6.1</td>\n",
       "      <td>2.3</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>136</th>\n",
       "      <td>6.3</td>\n",
       "      <td>3.4</td>\n",
       "      <td>5.6</td>\n",
       "      <td>2.4</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>137</th>\n",
       "      <td>6.4</td>\n",
       "      <td>3.1</td>\n",
       "      <td>5.5</td>\n",
       "      <td>1.8</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>138</th>\n",
       "      <td>6.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>4.8</td>\n",
       "      <td>1.8</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>139</th>\n",
       "      <td>6.9</td>\n",
       "      <td>3.1</td>\n",
       "      <td>5.4</td>\n",
       "      <td>2.1</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>140</th>\n",
       "      <td>6.7</td>\n",
       "      <td>3.1</td>\n",
       "      <td>5.6</td>\n",
       "      <td>2.4</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>141</th>\n",
       "      <td>6.9</td>\n",
       "      <td>3.1</td>\n",
       "      <td>5.1</td>\n",
       "      <td>2.3</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>142</th>\n",
       "      <td>5.8</td>\n",
       "      <td>2.7</td>\n",
       "      <td>5.1</td>\n",
       "      <td>1.9</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>143</th>\n",
       "      <td>6.8</td>\n",
       "      <td>3.2</td>\n",
       "      <td>5.9</td>\n",
       "      <td>2.3</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>144</th>\n",
       "      <td>6.7</td>\n",
       "      <td>3.3</td>\n",
       "      <td>5.7</td>\n",
       "      <td>2.5</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>145</th>\n",
       "      <td>6.7</td>\n",
       "      <td>3.0</td>\n",
       "      <td>5.2</td>\n",
       "      <td>2.3</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146</th>\n",
       "      <td>6.3</td>\n",
       "      <td>2.5</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1.9</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>147</th>\n",
       "      <td>6.5</td>\n",
       "      <td>3.0</td>\n",
       "      <td>5.2</td>\n",
       "      <td>2.0</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>148</th>\n",
       "      <td>6.2</td>\n",
       "      <td>3.4</td>\n",
       "      <td>5.4</td>\n",
       "      <td>2.3</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>149</th>\n",
       "      <td>5.9</td>\n",
       "      <td>3.0</td>\n",
       "      <td>5.1</td>\n",
       "      <td>1.8</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>150 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     sepal length  sepal width  petal length  petal width           class  \\\n",
       "0             5.1          3.5           1.4          0.2     Iris-setosa   \n",
       "1             4.9          3.0           1.4          0.2     Iris-setosa   \n",
       "2             4.7          3.2           1.3          0.2     Iris-setosa   \n",
       "3             4.6          3.1           1.5          0.2     Iris-setosa   \n",
       "4             5.0          3.6           1.4          0.2     Iris-setosa   \n",
       "5             5.4          3.9           1.7          0.4     Iris-setosa   \n",
       "6             4.6          3.4           1.4          0.3     Iris-setosa   \n",
       "7             5.0          3.4           1.5          0.2     Iris-setosa   \n",
       "8             4.4          2.9           1.4          0.2     Iris-setosa   \n",
       "9             4.9          3.1           1.5          0.1     Iris-setosa   \n",
       "10            5.4          3.7           1.5          0.2     Iris-setosa   \n",
       "11            4.8          3.4           1.6          0.2     Iris-setosa   \n",
       "12            4.8          3.0           1.4          0.1     Iris-setosa   \n",
       "13            4.3          3.0           1.1          0.1     Iris-setosa   \n",
       "14            5.8          4.0           1.2          0.2     Iris-setosa   \n",
       "15            5.7          4.4           1.5          0.4     Iris-setosa   \n",
       "16            5.4          3.9           1.3          0.4     Iris-setosa   \n",
       "17            5.1          3.5           1.4          0.3     Iris-setosa   \n",
       "18            5.7          3.8           1.7          0.3     Iris-setosa   \n",
       "19            5.1          3.8           1.5          0.3     Iris-setosa   \n",
       "20            5.4          3.4           1.7          0.2     Iris-setosa   \n",
       "21            5.1          3.7           1.5          0.4     Iris-setosa   \n",
       "22            4.6          3.6           1.0          0.2     Iris-setosa   \n",
       "23            5.1          3.3           1.7          0.5     Iris-setosa   \n",
       "24            4.8          3.4           1.9          0.2     Iris-setosa   \n",
       "25            5.0          3.0           1.6          0.2     Iris-setosa   \n",
       "26            5.0          3.4           1.6          0.4     Iris-setosa   \n",
       "27            5.2          3.5           1.5          0.2     Iris-setosa   \n",
       "28            5.2          3.4           1.4          0.2     Iris-setosa   \n",
       "29            4.7          3.2           1.6          0.2     Iris-setosa   \n",
       "..            ...          ...           ...          ...             ...   \n",
       "120           6.9          3.2           5.7          2.3  Iris-virginica   \n",
       "121           5.6          2.8           4.9          2.0  Iris-virginica   \n",
       "122           7.7          2.8           6.7          2.0  Iris-virginica   \n",
       "123           6.3          2.7           4.9          1.8  Iris-virginica   \n",
       "124           6.7          3.3           5.7          2.1  Iris-virginica   \n",
       "125           7.2          3.2           6.0          1.8  Iris-virginica   \n",
       "126           6.2          2.8           4.8          1.8  Iris-virginica   \n",
       "127           6.1          3.0           4.9          1.8  Iris-virginica   \n",
       "128           6.4          2.8           5.6          2.1  Iris-virginica   \n",
       "129           7.2          3.0           5.8          1.6  Iris-virginica   \n",
       "130           7.4          2.8           6.1          1.9  Iris-virginica   \n",
       "131           7.9          3.8           6.4          2.0  Iris-virginica   \n",
       "132           6.4          2.8           5.6          2.2  Iris-virginica   \n",
       "133           6.3          2.8           5.1          1.5  Iris-virginica   \n",
       "134           6.1          2.6           5.6          1.4  Iris-virginica   \n",
       "135           7.7          3.0           6.1          2.3  Iris-virginica   \n",
       "136           6.3          3.4           5.6          2.4  Iris-virginica   \n",
       "137           6.4          3.1           5.5          1.8  Iris-virginica   \n",
       "138           6.0          3.0           4.8          1.8  Iris-virginica   \n",
       "139           6.9          3.1           5.4          2.1  Iris-virginica   \n",
       "140           6.7          3.1           5.6          2.4  Iris-virginica   \n",
       "141           6.9          3.1           5.1          2.3  Iris-virginica   \n",
       "142           5.8          2.7           5.1          1.9  Iris-virginica   \n",
       "143           6.8          3.2           5.9          2.3  Iris-virginica   \n",
       "144           6.7          3.3           5.7          2.5  Iris-virginica   \n",
       "145           6.7          3.0           5.2          2.3  Iris-virginica   \n",
       "146           6.3          2.5           5.0          1.9  Iris-virginica   \n",
       "147           6.5          3.0           5.2          2.0  Iris-virginica   \n",
       "148           6.2          3.4           5.4          2.3  Iris-virginica   \n",
       "149           5.9          3.0           5.1          1.8  Iris-virginica   \n",
       "\n",
       "    short-class  wide petal  \n",
       "0           SET           0  \n",
       "1           SET           0  \n",
       "2           SET           0  \n",
       "3           SET           0  \n",
       "4           SET           0  \n",
       "5           SET           0  \n",
       "6           SET           0  \n",
       "7           SET           0  \n",
       "8           SET           0  \n",
       "9           SET           0  \n",
       "10          SET           0  \n",
       "11          SET           0  \n",
       "12          SET           0  \n",
       "13          SET           0  \n",
       "14          SET           0  \n",
       "15          SET           0  \n",
       "16          SET           0  \n",
       "17          SET           0  \n",
       "18          SET           0  \n",
       "19          SET           0  \n",
       "20          SET           0  \n",
       "21          SET           0  \n",
       "22          SET           0  \n",
       "23          SET           0  \n",
       "24          SET           0  \n",
       "25          SET           0  \n",
       "26          SET           0  \n",
       "27          SET           0  \n",
       "28          SET           0  \n",
       "29          SET           0  \n",
       "..          ...         ...  \n",
       "120         VIR           1  \n",
       "121         VIR           1  \n",
       "122         VIR           1  \n",
       "123         VIR           1  \n",
       "124         VIR           1  \n",
       "125         VIR           1  \n",
       "126         VIR           1  \n",
       "127         VIR           1  \n",
       "128         VIR           1  \n",
       "129         VIR           1  \n",
       "130         VIR           1  \n",
       "131         VIR           1  \n",
       "132         VIR           1  \n",
       "133         VIR           1  \n",
       "134         VIR           1  \n",
       "135         VIR           1  \n",
       "136         VIR           1  \n",
       "137         VIR           1  \n",
       "138         VIR           1  \n",
       "139         VIR           1  \n",
       "140         VIR           1  \n",
       "141         VIR           1  \n",
       "142         VIR           1  \n",
       "143         VIR           1  \n",
       "144         VIR           1  \n",
       "145         VIR           1  \n",
       "146         VIR           1  \n",
       "147         VIR           1  \n",
       "148         VIR           1  \n",
       "149         VIR           1  \n",
       "\n",
       "[150 rows x 7 columns]"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"wide petal\"] = df[\"petal width\"].apply(lambda v: 1 if v >= 1.3 else 0); df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>sepal length</th>\n",
       "      <th>sepal width</th>\n",
       "      <th>petal length</th>\n",
       "      <th>petal width</th>\n",
       "      <th>class</th>\n",
       "      <th>short-class</th>\n",
       "      <th>wide petal</th>\n",
       "      <th>petal area</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5.1</td>\n",
       "      <td>3.5</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>4.9</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>4.7</td>\n",
       "      <td>3.2</td>\n",
       "      <td>1.3</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4.6</td>\n",
       "      <td>3.1</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5.0</td>\n",
       "      <td>3.6</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>5.4</td>\n",
       "      <td>3.9</td>\n",
       "      <td>1.7</td>\n",
       "      <td>0.4</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>4.6</td>\n",
       "      <td>3.4</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.3</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>5.0</td>\n",
       "      <td>3.4</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>4.4</td>\n",
       "      <td>2.9</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>4.9</td>\n",
       "      <td>3.1</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.1</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>5.4</td>\n",
       "      <td>3.7</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>4.8</td>\n",
       "      <td>3.4</td>\n",
       "      <td>1.6</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>4.8</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.1</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>4.3</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.1</td>\n",
       "      <td>0.1</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>5.8</td>\n",
       "      <td>4.0</td>\n",
       "      <td>1.2</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>5.7</td>\n",
       "      <td>4.4</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.4</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>5.4</td>\n",
       "      <td>3.9</td>\n",
       "      <td>1.3</td>\n",
       "      <td>0.4</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.52</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>5.1</td>\n",
       "      <td>3.5</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.3</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>5.7</td>\n",
       "      <td>3.8</td>\n",
       "      <td>1.7</td>\n",
       "      <td>0.3</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.51</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>5.1</td>\n",
       "      <td>3.8</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.3</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.45</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>5.4</td>\n",
       "      <td>3.4</td>\n",
       "      <td>1.7</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>5.1</td>\n",
       "      <td>3.7</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.4</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>4.6</td>\n",
       "      <td>3.6</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>5.1</td>\n",
       "      <td>3.3</td>\n",
       "      <td>1.7</td>\n",
       "      <td>0.5</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.85</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>4.8</td>\n",
       "      <td>3.4</td>\n",
       "      <td>1.9</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>5.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.6</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>5.0</td>\n",
       "      <td>3.4</td>\n",
       "      <td>1.6</td>\n",
       "      <td>0.4</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>5.2</td>\n",
       "      <td>3.5</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>5.2</td>\n",
       "      <td>3.4</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>4.7</td>\n",
       "      <td>3.2</td>\n",
       "      <td>1.6</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>0.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>120</th>\n",
       "      <td>6.9</td>\n",
       "      <td>3.2</td>\n",
       "      <td>5.7</td>\n",
       "      <td>2.3</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>13.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>121</th>\n",
       "      <td>5.6</td>\n",
       "      <td>2.8</td>\n",
       "      <td>4.9</td>\n",
       "      <td>2.0</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>9.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>122</th>\n",
       "      <td>7.7</td>\n",
       "      <td>2.8</td>\n",
       "      <td>6.7</td>\n",
       "      <td>2.0</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>13.40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>123</th>\n",
       "      <td>6.3</td>\n",
       "      <td>2.7</td>\n",
       "      <td>4.9</td>\n",
       "      <td>1.8</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>8.82</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>124</th>\n",
       "      <td>6.7</td>\n",
       "      <td>3.3</td>\n",
       "      <td>5.7</td>\n",
       "      <td>2.1</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>11.97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>125</th>\n",
       "      <td>7.2</td>\n",
       "      <td>3.2</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1.8</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>10.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>126</th>\n",
       "      <td>6.2</td>\n",
       "      <td>2.8</td>\n",
       "      <td>4.8</td>\n",
       "      <td>1.8</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>8.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>127</th>\n",
       "      <td>6.1</td>\n",
       "      <td>3.0</td>\n",
       "      <td>4.9</td>\n",
       "      <td>1.8</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>8.82</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>128</th>\n",
       "      <td>6.4</td>\n",
       "      <td>2.8</td>\n",
       "      <td>5.6</td>\n",
       "      <td>2.1</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>11.76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>129</th>\n",
       "      <td>7.2</td>\n",
       "      <td>3.0</td>\n",
       "      <td>5.8</td>\n",
       "      <td>1.6</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>9.28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>130</th>\n",
       "      <td>7.4</td>\n",
       "      <td>2.8</td>\n",
       "      <td>6.1</td>\n",
       "      <td>1.9</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>11.59</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>131</th>\n",
       "      <td>7.9</td>\n",
       "      <td>3.8</td>\n",
       "      <td>6.4</td>\n",
       "      <td>2.0</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>12.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>132</th>\n",
       "      <td>6.4</td>\n",
       "      <td>2.8</td>\n",
       "      <td>5.6</td>\n",
       "      <td>2.2</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>12.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>133</th>\n",
       "      <td>6.3</td>\n",
       "      <td>2.8</td>\n",
       "      <td>5.1</td>\n",
       "      <td>1.5</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>7.65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>134</th>\n",
       "      <td>6.1</td>\n",
       "      <td>2.6</td>\n",
       "      <td>5.6</td>\n",
       "      <td>1.4</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>7.84</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>135</th>\n",
       "      <td>7.7</td>\n",
       "      <td>3.0</td>\n",
       "      <td>6.1</td>\n",
       "      <td>2.3</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>14.03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>136</th>\n",
       "      <td>6.3</td>\n",
       "      <td>3.4</td>\n",
       "      <td>5.6</td>\n",
       "      <td>2.4</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>13.44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>137</th>\n",
       "      <td>6.4</td>\n",
       "      <td>3.1</td>\n",
       "      <td>5.5</td>\n",
       "      <td>1.8</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>9.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>138</th>\n",
       "      <td>6.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>4.8</td>\n",
       "      <td>1.8</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>8.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>139</th>\n",
       "      <td>6.9</td>\n",
       "      <td>3.1</td>\n",
       "      <td>5.4</td>\n",
       "      <td>2.1</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>11.34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>140</th>\n",
       "      <td>6.7</td>\n",
       "      <td>3.1</td>\n",
       "      <td>5.6</td>\n",
       "      <td>2.4</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>13.44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>141</th>\n",
       "      <td>6.9</td>\n",
       "      <td>3.1</td>\n",
       "      <td>5.1</td>\n",
       "      <td>2.3</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>11.73</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>142</th>\n",
       "      <td>5.8</td>\n",
       "      <td>2.7</td>\n",
       "      <td>5.1</td>\n",
       "      <td>1.9</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>9.69</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>143</th>\n",
       "      <td>6.8</td>\n",
       "      <td>3.2</td>\n",
       "      <td>5.9</td>\n",
       "      <td>2.3</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>13.57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>144</th>\n",
       "      <td>6.7</td>\n",
       "      <td>3.3</td>\n",
       "      <td>5.7</td>\n",
       "      <td>2.5</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>14.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>145</th>\n",
       "      <td>6.7</td>\n",
       "      <td>3.0</td>\n",
       "      <td>5.2</td>\n",
       "      <td>2.3</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>11.96</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146</th>\n",
       "      <td>6.3</td>\n",
       "      <td>2.5</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1.9</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>9.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>147</th>\n",
       "      <td>6.5</td>\n",
       "      <td>3.0</td>\n",
       "      <td>5.2</td>\n",
       "      <td>2.0</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>10.40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>148</th>\n",
       "      <td>6.2</td>\n",
       "      <td>3.4</td>\n",
       "      <td>5.4</td>\n",
       "      <td>2.3</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>12.42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>149</th>\n",
       "      <td>5.9</td>\n",
       "      <td>3.0</td>\n",
       "      <td>5.1</td>\n",
       "      <td>1.8</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>9.18</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>150 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     sepal length  sepal width  petal length  petal width           class  \\\n",
       "0             5.1          3.5           1.4          0.2     Iris-setosa   \n",
       "1             4.9          3.0           1.4          0.2     Iris-setosa   \n",
       "2             4.7          3.2           1.3          0.2     Iris-setosa   \n",
       "3             4.6          3.1           1.5          0.2     Iris-setosa   \n",
       "4             5.0          3.6           1.4          0.2     Iris-setosa   \n",
       "5             5.4          3.9           1.7          0.4     Iris-setosa   \n",
       "6             4.6          3.4           1.4          0.3     Iris-setosa   \n",
       "7             5.0          3.4           1.5          0.2     Iris-setosa   \n",
       "8             4.4          2.9           1.4          0.2     Iris-setosa   \n",
       "9             4.9          3.1           1.5          0.1     Iris-setosa   \n",
       "10            5.4          3.7           1.5          0.2     Iris-setosa   \n",
       "11            4.8          3.4           1.6          0.2     Iris-setosa   \n",
       "12            4.8          3.0           1.4          0.1     Iris-setosa   \n",
       "13            4.3          3.0           1.1          0.1     Iris-setosa   \n",
       "14            5.8          4.0           1.2          0.2     Iris-setosa   \n",
       "15            5.7          4.4           1.5          0.4     Iris-setosa   \n",
       "16            5.4          3.9           1.3          0.4     Iris-setosa   \n",
       "17            5.1          3.5           1.4          0.3     Iris-setosa   \n",
       "18            5.7          3.8           1.7          0.3     Iris-setosa   \n",
       "19            5.1          3.8           1.5          0.3     Iris-setosa   \n",
       "20            5.4          3.4           1.7          0.2     Iris-setosa   \n",
       "21            5.1          3.7           1.5          0.4     Iris-setosa   \n",
       "22            4.6          3.6           1.0          0.2     Iris-setosa   \n",
       "23            5.1          3.3           1.7          0.5     Iris-setosa   \n",
       "24            4.8          3.4           1.9          0.2     Iris-setosa   \n",
       "25            5.0          3.0           1.6          0.2     Iris-setosa   \n",
       "26            5.0          3.4           1.6          0.4     Iris-setosa   \n",
       "27            5.2          3.5           1.5          0.2     Iris-setosa   \n",
       "28            5.2          3.4           1.4          0.2     Iris-setosa   \n",
       "29            4.7          3.2           1.6          0.2     Iris-setosa   \n",
       "..            ...          ...           ...          ...             ...   \n",
       "120           6.9          3.2           5.7          2.3  Iris-virginica   \n",
       "121           5.6          2.8           4.9          2.0  Iris-virginica   \n",
       "122           7.7          2.8           6.7          2.0  Iris-virginica   \n",
       "123           6.3          2.7           4.9          1.8  Iris-virginica   \n",
       "124           6.7          3.3           5.7          2.1  Iris-virginica   \n",
       "125           7.2          3.2           6.0          1.8  Iris-virginica   \n",
       "126           6.2          2.8           4.8          1.8  Iris-virginica   \n",
       "127           6.1          3.0           4.9          1.8  Iris-virginica   \n",
       "128           6.4          2.8           5.6          2.1  Iris-virginica   \n",
       "129           7.2          3.0           5.8          1.6  Iris-virginica   \n",
       "130           7.4          2.8           6.1          1.9  Iris-virginica   \n",
       "131           7.9          3.8           6.4          2.0  Iris-virginica   \n",
       "132           6.4          2.8           5.6          2.2  Iris-virginica   \n",
       "133           6.3          2.8           5.1          1.5  Iris-virginica   \n",
       "134           6.1          2.6           5.6          1.4  Iris-virginica   \n",
       "135           7.7          3.0           6.1          2.3  Iris-virginica   \n",
       "136           6.3          3.4           5.6          2.4  Iris-virginica   \n",
       "137           6.4          3.1           5.5          1.8  Iris-virginica   \n",
       "138           6.0          3.0           4.8          1.8  Iris-virginica   \n",
       "139           6.9          3.1           5.4          2.1  Iris-virginica   \n",
       "140           6.7          3.1           5.6          2.4  Iris-virginica   \n",
       "141           6.9          3.1           5.1          2.3  Iris-virginica   \n",
       "142           5.8          2.7           5.1          1.9  Iris-virginica   \n",
       "143           6.8          3.2           5.9          2.3  Iris-virginica   \n",
       "144           6.7          3.3           5.7          2.5  Iris-virginica   \n",
       "145           6.7          3.0           5.2          2.3  Iris-virginica   \n",
       "146           6.3          2.5           5.0          1.9  Iris-virginica   \n",
       "147           6.5          3.0           5.2          2.0  Iris-virginica   \n",
       "148           6.2          3.4           5.4          2.3  Iris-virginica   \n",
       "149           5.9          3.0           5.1          1.8  Iris-virginica   \n",
       "\n",
       "    short-class  wide petal  petal area  \n",
       "0           SET           0        0.28  \n",
       "1           SET           0        0.28  \n",
       "2           SET           0        0.26  \n",
       "3           SET           0        0.30  \n",
       "4           SET           0        0.28  \n",
       "5           SET           0        0.68  \n",
       "6           SET           0        0.42  \n",
       "7           SET           0        0.30  \n",
       "8           SET           0        0.28  \n",
       "9           SET           0        0.15  \n",
       "10          SET           0        0.30  \n",
       "11          SET           0        0.32  \n",
       "12          SET           0        0.14  \n",
       "13          SET           0        0.11  \n",
       "14          SET           0        0.24  \n",
       "15          SET           0        0.60  \n",
       "16          SET           0        0.52  \n",
       "17          SET           0        0.42  \n",
       "18          SET           0        0.51  \n",
       "19          SET           0        0.45  \n",
       "20          SET           0        0.34  \n",
       "21          SET           0        0.60  \n",
       "22          SET           0        0.20  \n",
       "23          SET           0        0.85  \n",
       "24          SET           0        0.38  \n",
       "25          SET           0        0.32  \n",
       "26          SET           0        0.64  \n",
       "27          SET           0        0.30  \n",
       "28          SET           0        0.28  \n",
       "29          SET           0        0.32  \n",
       "..          ...         ...         ...  \n",
       "120         VIR           1       13.11  \n",
       "121         VIR           1        9.80  \n",
       "122         VIR           1       13.40  \n",
       "123         VIR           1        8.82  \n",
       "124         VIR           1       11.97  \n",
       "125         VIR           1       10.80  \n",
       "126         VIR           1        8.64  \n",
       "127         VIR           1        8.82  \n",
       "128         VIR           1       11.76  \n",
       "129         VIR           1        9.28  \n",
       "130         VIR           1       11.59  \n",
       "131         VIR           1       12.80  \n",
       "132         VIR           1       12.32  \n",
       "133         VIR           1        7.65  \n",
       "134         VIR           1        7.84  \n",
       "135         VIR           1       14.03  \n",
       "136         VIR           1       13.44  \n",
       "137         VIR           1        9.90  \n",
       "138         VIR           1        8.64  \n",
       "139         VIR           1       11.34  \n",
       "140         VIR           1       13.44  \n",
       "141         VIR           1       11.73  \n",
       "142         VIR           1        9.69  \n",
       "143         VIR           1       13.57  \n",
       "144         VIR           1       14.25  \n",
       "145         VIR           1       11.96  \n",
       "146         VIR           1        9.50  \n",
       "147         VIR           1       10.40  \n",
       "148         VIR           1       12.42  \n",
       "149         VIR           1        9.18  \n",
       "\n",
       "[150 rows x 8 columns]"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# axis=1 表示告知 pandas 对行进行处理\n",
    "df[\"petal area\"] = df.apply(lambda r: r[\"petal length\"] * r[\"petal width\"], axis=1); df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1.3 Applymap"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>sepal length</th>\n",
       "      <th>sepal width</th>\n",
       "      <th>petal length</th>\n",
       "      <th>petal width</th>\n",
       "      <th>class</th>\n",
       "      <th>short-class</th>\n",
       "      <th>wide petal</th>\n",
       "      <th>petal area</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1.629241</td>\n",
       "      <td>1.252763</td>\n",
       "      <td>0.336472</td>\n",
       "      <td>-1.609438</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-1.272966</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1.589235</td>\n",
       "      <td>1.098612</td>\n",
       "      <td>0.336472</td>\n",
       "      <td>-1.609438</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-1.272966</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1.547563</td>\n",
       "      <td>1.163151</td>\n",
       "      <td>0.262364</td>\n",
       "      <td>-1.609438</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-1.347074</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1.526056</td>\n",
       "      <td>1.131402</td>\n",
       "      <td>0.405465</td>\n",
       "      <td>-1.609438</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-1.203973</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1.609438</td>\n",
       "      <td>1.280934</td>\n",
       "      <td>0.336472</td>\n",
       "      <td>-1.609438</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-1.272966</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1.686399</td>\n",
       "      <td>1.360977</td>\n",
       "      <td>0.530628</td>\n",
       "      <td>-0.916291</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-0.385662</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>1.526056</td>\n",
       "      <td>1.223775</td>\n",
       "      <td>0.336472</td>\n",
       "      <td>-1.203973</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-0.867501</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>1.609438</td>\n",
       "      <td>1.223775</td>\n",
       "      <td>0.405465</td>\n",
       "      <td>-1.609438</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-1.203973</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>1.481605</td>\n",
       "      <td>1.064711</td>\n",
       "      <td>0.336472</td>\n",
       "      <td>-1.609438</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-1.272966</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>1.589235</td>\n",
       "      <td>1.131402</td>\n",
       "      <td>0.405465</td>\n",
       "      <td>-2.302585</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-1.897120</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>1.686399</td>\n",
       "      <td>1.308333</td>\n",
       "      <td>0.405465</td>\n",
       "      <td>-1.609438</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-1.203973</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>1.568616</td>\n",
       "      <td>1.223775</td>\n",
       "      <td>0.470004</td>\n",
       "      <td>-1.609438</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-1.139434</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>1.568616</td>\n",
       "      <td>1.098612</td>\n",
       "      <td>0.336472</td>\n",
       "      <td>-2.302585</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-1.966113</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>1.458615</td>\n",
       "      <td>1.098612</td>\n",
       "      <td>0.095310</td>\n",
       "      <td>-2.302585</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-2.207275</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>1.757858</td>\n",
       "      <td>1.386294</td>\n",
       "      <td>0.182322</td>\n",
       "      <td>-1.609438</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-1.427116</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>1.740466</td>\n",
       "      <td>1.481605</td>\n",
       "      <td>0.405465</td>\n",
       "      <td>-0.916291</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-0.510826</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>1.686399</td>\n",
       "      <td>1.360977</td>\n",
       "      <td>0.262364</td>\n",
       "      <td>-0.916291</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-0.653926</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>1.629241</td>\n",
       "      <td>1.252763</td>\n",
       "      <td>0.336472</td>\n",
       "      <td>-1.203973</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-0.867501</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>1.740466</td>\n",
       "      <td>1.335001</td>\n",
       "      <td>0.530628</td>\n",
       "      <td>-1.203973</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-0.673345</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>1.629241</td>\n",
       "      <td>1.335001</td>\n",
       "      <td>0.405465</td>\n",
       "      <td>-1.203973</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-0.798508</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>1.686399</td>\n",
       "      <td>1.223775</td>\n",
       "      <td>0.530628</td>\n",
       "      <td>-1.609438</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-1.078810</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>1.629241</td>\n",
       "      <td>1.308333</td>\n",
       "      <td>0.405465</td>\n",
       "      <td>-0.916291</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-0.510826</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>1.526056</td>\n",
       "      <td>1.280934</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>-1.609438</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-1.609438</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>1.629241</td>\n",
       "      <td>1.193922</td>\n",
       "      <td>0.530628</td>\n",
       "      <td>-0.693147</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-0.162519</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>1.568616</td>\n",
       "      <td>1.223775</td>\n",
       "      <td>0.641854</td>\n",
       "      <td>-1.609438</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-0.967584</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>1.609438</td>\n",
       "      <td>1.098612</td>\n",
       "      <td>0.470004</td>\n",
       "      <td>-1.609438</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-1.139434</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>1.609438</td>\n",
       "      <td>1.223775</td>\n",
       "      <td>0.470004</td>\n",
       "      <td>-0.916291</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-0.446287</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>1.648659</td>\n",
       "      <td>1.252763</td>\n",
       "      <td>0.405465</td>\n",
       "      <td>-1.609438</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-1.203973</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>1.648659</td>\n",
       "      <td>1.223775</td>\n",
       "      <td>0.336472</td>\n",
       "      <td>-1.609438</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-1.272966</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>1.547563</td>\n",
       "      <td>1.163151</td>\n",
       "      <td>0.470004</td>\n",
       "      <td>-1.609438</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>SET</td>\n",
       "      <td>0</td>\n",
       "      <td>-1.139434</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>120</th>\n",
       "      <td>1.931521</td>\n",
       "      <td>1.163151</td>\n",
       "      <td>1.740466</td>\n",
       "      <td>0.832909</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.573375</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>121</th>\n",
       "      <td>1.722767</td>\n",
       "      <td>1.029619</td>\n",
       "      <td>1.589235</td>\n",
       "      <td>0.693147</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.282382</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>122</th>\n",
       "      <td>2.041220</td>\n",
       "      <td>1.029619</td>\n",
       "      <td>1.902108</td>\n",
       "      <td>0.693147</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.595255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>123</th>\n",
       "      <td>1.840550</td>\n",
       "      <td>0.993252</td>\n",
       "      <td>1.589235</td>\n",
       "      <td>0.587787</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.177022</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>124</th>\n",
       "      <td>1.902108</td>\n",
       "      <td>1.193922</td>\n",
       "      <td>1.740466</td>\n",
       "      <td>0.741937</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.482404</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>125</th>\n",
       "      <td>1.974081</td>\n",
       "      <td>1.163151</td>\n",
       "      <td>1.791759</td>\n",
       "      <td>0.587787</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.379546</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>126</th>\n",
       "      <td>1.824549</td>\n",
       "      <td>1.029619</td>\n",
       "      <td>1.568616</td>\n",
       "      <td>0.587787</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.156403</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>127</th>\n",
       "      <td>1.808289</td>\n",
       "      <td>1.098612</td>\n",
       "      <td>1.589235</td>\n",
       "      <td>0.587787</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.177022</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>128</th>\n",
       "      <td>1.856298</td>\n",
       "      <td>1.029619</td>\n",
       "      <td>1.722767</td>\n",
       "      <td>0.741937</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.464704</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>129</th>\n",
       "      <td>1.974081</td>\n",
       "      <td>1.098612</td>\n",
       "      <td>1.757858</td>\n",
       "      <td>0.470004</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.227862</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>130</th>\n",
       "      <td>2.001480</td>\n",
       "      <td>1.029619</td>\n",
       "      <td>1.808289</td>\n",
       "      <td>0.641854</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.450143</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>131</th>\n",
       "      <td>2.066863</td>\n",
       "      <td>1.335001</td>\n",
       "      <td>1.856298</td>\n",
       "      <td>0.693147</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.549445</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>132</th>\n",
       "      <td>1.856298</td>\n",
       "      <td>1.029619</td>\n",
       "      <td>1.722767</td>\n",
       "      <td>0.788457</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.511224</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>133</th>\n",
       "      <td>1.840550</td>\n",
       "      <td>1.029619</td>\n",
       "      <td>1.629241</td>\n",
       "      <td>0.405465</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.034706</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>134</th>\n",
       "      <td>1.808289</td>\n",
       "      <td>0.955511</td>\n",
       "      <td>1.722767</td>\n",
       "      <td>0.336472</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.059239</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>135</th>\n",
       "      <td>2.041220</td>\n",
       "      <td>1.098612</td>\n",
       "      <td>1.808289</td>\n",
       "      <td>0.832909</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.641198</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>136</th>\n",
       "      <td>1.840550</td>\n",
       "      <td>1.223775</td>\n",
       "      <td>1.722767</td>\n",
       "      <td>0.875469</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.598235</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>137</th>\n",
       "      <td>1.856298</td>\n",
       "      <td>1.131402</td>\n",
       "      <td>1.704748</td>\n",
       "      <td>0.587787</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.292535</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>138</th>\n",
       "      <td>1.791759</td>\n",
       "      <td>1.098612</td>\n",
       "      <td>1.568616</td>\n",
       "      <td>0.587787</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.156403</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>139</th>\n",
       "      <td>1.931521</td>\n",
       "      <td>1.131402</td>\n",
       "      <td>1.686399</td>\n",
       "      <td>0.741937</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.428336</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>140</th>\n",
       "      <td>1.902108</td>\n",
       "      <td>1.131402</td>\n",
       "      <td>1.722767</td>\n",
       "      <td>0.875469</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.598235</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>141</th>\n",
       "      <td>1.931521</td>\n",
       "      <td>1.131402</td>\n",
       "      <td>1.629241</td>\n",
       "      <td>0.832909</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.462150</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>142</th>\n",
       "      <td>1.757858</td>\n",
       "      <td>0.993252</td>\n",
       "      <td>1.629241</td>\n",
       "      <td>0.641854</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.271094</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>143</th>\n",
       "      <td>1.916923</td>\n",
       "      <td>1.163151</td>\n",
       "      <td>1.774952</td>\n",
       "      <td>0.832909</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.607861</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>144</th>\n",
       "      <td>1.902108</td>\n",
       "      <td>1.193922</td>\n",
       "      <td>1.740466</td>\n",
       "      <td>0.916291</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.656757</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>145</th>\n",
       "      <td>1.902108</td>\n",
       "      <td>1.098612</td>\n",
       "      <td>1.648659</td>\n",
       "      <td>0.832909</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.481568</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146</th>\n",
       "      <td>1.840550</td>\n",
       "      <td>0.916291</td>\n",
       "      <td>1.609438</td>\n",
       "      <td>0.641854</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.251292</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>147</th>\n",
       "      <td>1.871802</td>\n",
       "      <td>1.098612</td>\n",
       "      <td>1.648659</td>\n",
       "      <td>0.693147</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.341806</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>148</th>\n",
       "      <td>1.824549</td>\n",
       "      <td>1.223775</td>\n",
       "      <td>1.686399</td>\n",
       "      <td>0.832909</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.519308</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>149</th>\n",
       "      <td>1.774952</td>\n",
       "      <td>1.098612</td>\n",
       "      <td>1.629241</td>\n",
       "      <td>0.587787</td>\n",
       "      <td>Iris-virginica</td>\n",
       "      <td>VIR</td>\n",
       "      <td>1</td>\n",
       "      <td>2.217027</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>150 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     sepal length  sepal width  petal length  petal width           class  \\\n",
       "0        1.629241     1.252763      0.336472    -1.609438     Iris-setosa   \n",
       "1        1.589235     1.098612      0.336472    -1.609438     Iris-setosa   \n",
       "2        1.547563     1.163151      0.262364    -1.609438     Iris-setosa   \n",
       "3        1.526056     1.131402      0.405465    -1.609438     Iris-setosa   \n",
       "4        1.609438     1.280934      0.336472    -1.609438     Iris-setosa   \n",
       "5        1.686399     1.360977      0.530628    -0.916291     Iris-setosa   \n",
       "6        1.526056     1.223775      0.336472    -1.203973     Iris-setosa   \n",
       "7        1.609438     1.223775      0.405465    -1.609438     Iris-setosa   \n",
       "8        1.481605     1.064711      0.336472    -1.609438     Iris-setosa   \n",
       "9        1.589235     1.131402      0.405465    -2.302585     Iris-setosa   \n",
       "10       1.686399     1.308333      0.405465    -1.609438     Iris-setosa   \n",
       "11       1.568616     1.223775      0.470004    -1.609438     Iris-setosa   \n",
       "12       1.568616     1.098612      0.336472    -2.302585     Iris-setosa   \n",
       "13       1.458615     1.098612      0.095310    -2.302585     Iris-setosa   \n",
       "14       1.757858     1.386294      0.182322    -1.609438     Iris-setosa   \n",
       "15       1.740466     1.481605      0.405465    -0.916291     Iris-setosa   \n",
       "16       1.686399     1.360977      0.262364    -0.916291     Iris-setosa   \n",
       "17       1.629241     1.252763      0.336472    -1.203973     Iris-setosa   \n",
       "18       1.740466     1.335001      0.530628    -1.203973     Iris-setosa   \n",
       "19       1.629241     1.335001      0.405465    -1.203973     Iris-setosa   \n",
       "20       1.686399     1.223775      0.530628    -1.609438     Iris-setosa   \n",
       "21       1.629241     1.308333      0.405465    -0.916291     Iris-setosa   \n",
       "22       1.526056     1.280934      0.000000    -1.609438     Iris-setosa   \n",
       "23       1.629241     1.193922      0.530628    -0.693147     Iris-setosa   \n",
       "24       1.568616     1.223775      0.641854    -1.609438     Iris-setosa   \n",
       "25       1.609438     1.098612      0.470004    -1.609438     Iris-setosa   \n",
       "26       1.609438     1.223775      0.470004    -0.916291     Iris-setosa   \n",
       "27       1.648659     1.252763      0.405465    -1.609438     Iris-setosa   \n",
       "28       1.648659     1.223775      0.336472    -1.609438     Iris-setosa   \n",
       "29       1.547563     1.163151      0.470004    -1.609438     Iris-setosa   \n",
       "..            ...          ...           ...          ...             ...   \n",
       "120      1.931521     1.163151      1.740466     0.832909  Iris-virginica   \n",
       "121      1.722767     1.029619      1.589235     0.693147  Iris-virginica   \n",
       "122      2.041220     1.029619      1.902108     0.693147  Iris-virginica   \n",
       "123      1.840550     0.993252      1.589235     0.587787  Iris-virginica   \n",
       "124      1.902108     1.193922      1.740466     0.741937  Iris-virginica   \n",
       "125      1.974081     1.163151      1.791759     0.587787  Iris-virginica   \n",
       "126      1.824549     1.029619      1.568616     0.587787  Iris-virginica   \n",
       "127      1.808289     1.098612      1.589235     0.587787  Iris-virginica   \n",
       "128      1.856298     1.029619      1.722767     0.741937  Iris-virginica   \n",
       "129      1.974081     1.098612      1.757858     0.470004  Iris-virginica   \n",
       "130      2.001480     1.029619      1.808289     0.641854  Iris-virginica   \n",
       "131      2.066863     1.335001      1.856298     0.693147  Iris-virginica   \n",
       "132      1.856298     1.029619      1.722767     0.788457  Iris-virginica   \n",
       "133      1.840550     1.029619      1.629241     0.405465  Iris-virginica   \n",
       "134      1.808289     0.955511      1.722767     0.336472  Iris-virginica   \n",
       "135      2.041220     1.098612      1.808289     0.832909  Iris-virginica   \n",
       "136      1.840550     1.223775      1.722767     0.875469  Iris-virginica   \n",
       "137      1.856298     1.131402      1.704748     0.587787  Iris-virginica   \n",
       "138      1.791759     1.098612      1.568616     0.587787  Iris-virginica   \n",
       "139      1.931521     1.131402      1.686399     0.741937  Iris-virginica   \n",
       "140      1.902108     1.131402      1.722767     0.875469  Iris-virginica   \n",
       "141      1.931521     1.131402      1.629241     0.832909  Iris-virginica   \n",
       "142      1.757858     0.993252      1.629241     0.641854  Iris-virginica   \n",
       "143      1.916923     1.163151      1.774952     0.832909  Iris-virginica   \n",
       "144      1.902108     1.193922      1.740466     0.916291  Iris-virginica   \n",
       "145      1.902108     1.098612      1.648659     0.832909  Iris-virginica   \n",
       "146      1.840550     0.916291      1.609438     0.641854  Iris-virginica   \n",
       "147      1.871802     1.098612      1.648659     0.693147  Iris-virginica   \n",
       "148      1.824549     1.223775      1.686399     0.832909  Iris-virginica   \n",
       "149      1.774952     1.098612      1.629241     0.587787  Iris-virginica   \n",
       "\n",
       "    short-class  wide petal  petal area  \n",
       "0           SET           0   -1.272966  \n",
       "1           SET           0   -1.272966  \n",
       "2           SET           0   -1.347074  \n",
       "3           SET           0   -1.203973  \n",
       "4           SET           0   -1.272966  \n",
       "5           SET           0   -0.385662  \n",
       "6           SET           0   -0.867501  \n",
       "7           SET           0   -1.203973  \n",
       "8           SET           0   -1.272966  \n",
       "9           SET           0   -1.897120  \n",
       "10          SET           0   -1.203973  \n",
       "11          SET           0   -1.139434  \n",
       "12          SET           0   -1.966113  \n",
       "13          SET           0   -2.207275  \n",
       "14          SET           0   -1.427116  \n",
       "15          SET           0   -0.510826  \n",
       "16          SET           0   -0.653926  \n",
       "17          SET           0   -0.867501  \n",
       "18          SET           0   -0.673345  \n",
       "19          SET           0   -0.798508  \n",
       "20          SET           0   -1.078810  \n",
       "21          SET           0   -0.510826  \n",
       "22          SET           0   -1.609438  \n",
       "23          SET           0   -0.162519  \n",
       "24          SET           0   -0.967584  \n",
       "25          SET           0   -1.139434  \n",
       "26          SET           0   -0.446287  \n",
       "27          SET           0   -1.203973  \n",
       "28          SET           0   -1.272966  \n",
       "29          SET           0   -1.139434  \n",
       "..          ...         ...         ...  \n",
       "120         VIR           1    2.573375  \n",
       "121         VIR           1    2.282382  \n",
       "122         VIR           1    2.595255  \n",
       "123         VIR           1    2.177022  \n",
       "124         VIR           1    2.482404  \n",
       "125         VIR           1    2.379546  \n",
       "126         VIR           1    2.156403  \n",
       "127         VIR           1    2.177022  \n",
       "128         VIR           1    2.464704  \n",
       "129         VIR           1    2.227862  \n",
       "130         VIR           1    2.450143  \n",
       "131         VIR           1    2.549445  \n",
       "132         VIR           1    2.511224  \n",
       "133         VIR           1    2.034706  \n",
       "134         VIR           1    2.059239  \n",
       "135         VIR           1    2.641198  \n",
       "136         VIR           1    2.598235  \n",
       "137         VIR           1    2.292535  \n",
       "138         VIR           1    2.156403  \n",
       "139         VIR           1    2.428336  \n",
       "140         VIR           1    2.598235  \n",
       "141         VIR           1    2.462150  \n",
       "142         VIR           1    2.271094  \n",
       "143         VIR           1    2.607861  \n",
       "144         VIR           1    2.656757  \n",
       "145         VIR           1    2.481568  \n",
       "146         VIR           1    2.251292  \n",
       "147         VIR           1    2.341806  \n",
       "148         VIR           1    2.519308  \n",
       "149         VIR           1    2.217027  \n",
       "\n",
       "[150 rows x 8 columns]"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.applymap(lambda v: np.log(v) if isinstance(v, float) else v)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1.4 Groupby"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>sepal length</th>\n",
       "      <th>sepal width</th>\n",
       "      <th>petal length</th>\n",
       "      <th>petal width</th>\n",
       "      <th>wide petal</th>\n",
       "      <th>petal area</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>class</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Iris-setosa</th>\n",
       "      <td>5.006</td>\n",
       "      <td>3.418</td>\n",
       "      <td>1.464</td>\n",
       "      <td>0.244</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.3628</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Iris-versicolor</th>\n",
       "      <td>5.936</td>\n",
       "      <td>2.770</td>\n",
       "      <td>4.260</td>\n",
       "      <td>1.326</td>\n",
       "      <td>0.7</td>\n",
       "      <td>5.7204</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Iris-virginica</th>\n",
       "      <td>6.588</td>\n",
       "      <td>2.974</td>\n",
       "      <td>5.552</td>\n",
       "      <td>2.026</td>\n",
       "      <td>1.0</td>\n",
       "      <td>11.2962</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                 sepal length  sepal width  petal length  petal width  \\\n",
       "class                                                                   \n",
       "Iris-setosa             5.006        3.418         1.464        0.244   \n",
       "Iris-versicolor         5.936        2.770         4.260        1.326   \n",
       "Iris-virginica          6.588        2.974         5.552        2.026   \n",
       "\n",
       "                 wide petal  petal area  \n",
       "class                                    \n",
       "Iris-setosa             0.0      0.3628  \n",
       "Iris-versicolor         0.7      5.7204  \n",
       "Iris-virginica          1.0     11.2962  "
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.groupby(\"class\").mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr:last-of-type th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th colspan=\"8\" halign=\"left\">petal area</th>\n",
       "      <th colspan=\"2\" halign=\"left\">petal length</th>\n",
       "      <th>...</th>\n",
       "      <th colspan=\"2\" halign=\"left\">sepal width</th>\n",
       "      <th colspan=\"8\" halign=\"left\">wide petal</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th>count</th>\n",
       "      <th>mean</th>\n",
       "      <th>std</th>\n",
       "      <th>min</th>\n",
       "      <th>25%</th>\n",
       "      <th>50%</th>\n",
       "      <th>75%</th>\n",
       "      <th>max</th>\n",
       "      <th>count</th>\n",
       "      <th>mean</th>\n",
       "      <th>...</th>\n",
       "      <th>75%</th>\n",
       "      <th>max</th>\n",
       "      <th>count</th>\n",
       "      <th>mean</th>\n",
       "      <th>std</th>\n",
       "      <th>min</th>\n",
       "      <th>25%</th>\n",
       "      <th>50%</th>\n",
       "      <th>75%</th>\n",
       "      <th>max</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>class</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Iris-setosa</th>\n",
       "      <td>50.0</td>\n",
       "      <td>0.3628</td>\n",
       "      <td>0.183248</td>\n",
       "      <td>0.11</td>\n",
       "      <td>0.2650</td>\n",
       "      <td>0.300</td>\n",
       "      <td>0.42</td>\n",
       "      <td>0.96</td>\n",
       "      <td>50.0</td>\n",
       "      <td>1.464</td>\n",
       "      <td>...</td>\n",
       "      <td>3.675</td>\n",
       "      <td>4.4</td>\n",
       "      <td>50.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Iris-versicolor</th>\n",
       "      <td>50.0</td>\n",
       "      <td>5.7204</td>\n",
       "      <td>1.368403</td>\n",
       "      <td>3.30</td>\n",
       "      <td>4.8600</td>\n",
       "      <td>5.615</td>\n",
       "      <td>6.75</td>\n",
       "      <td>8.64</td>\n",
       "      <td>50.0</td>\n",
       "      <td>4.260</td>\n",
       "      <td>...</td>\n",
       "      <td>3.000</td>\n",
       "      <td>3.4</td>\n",
       "      <td>50.0</td>\n",
       "      <td>0.7</td>\n",
       "      <td>0.46291</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Iris-virginica</th>\n",
       "      <td>50.0</td>\n",
       "      <td>11.2962</td>\n",
       "      <td>2.157412</td>\n",
       "      <td>7.50</td>\n",
       "      <td>9.7175</td>\n",
       "      <td>11.445</td>\n",
       "      <td>12.79</td>\n",
       "      <td>15.87</td>\n",
       "      <td>50.0</td>\n",
       "      <td>5.552</td>\n",
       "      <td>...</td>\n",
       "      <td>3.175</td>\n",
       "      <td>3.8</td>\n",
       "      <td>50.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3 rows × 48 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                petal area                                                  \\\n",
       "                     count     mean       std   min     25%     50%    75%   \n",
       "class                                                                        \n",
       "Iris-setosa           50.0   0.3628  0.183248  0.11  0.2650   0.300   0.42   \n",
       "Iris-versicolor       50.0   5.7204  1.368403  3.30  4.8600   5.615   6.75   \n",
       "Iris-virginica        50.0  11.2962  2.157412  7.50  9.7175  11.445  12.79   \n",
       "\n",
       "                       petal length        ...  sepal width      wide petal  \\\n",
       "                   max        count   mean ...          75%  max      count   \n",
       "class                                      ...                                \n",
       "Iris-setosa       0.96         50.0  1.464 ...        3.675  4.4       50.0   \n",
       "Iris-versicolor   8.64         50.0  4.260 ...        3.000  3.4       50.0   \n",
       "Iris-virginica   15.87         50.0  5.552 ...        3.175  3.8       50.0   \n",
       "\n",
       "                                                        \n",
       "                mean      std  min  25%  50%  75%  max  \n",
       "class                                                   \n",
       "Iris-setosa      0.0  0.00000  0.0  0.0  0.0  0.0  0.0  \n",
       "Iris-versicolor  0.7  0.46291  0.0  0.0  1.0  1.0  1.0  \n",
       "Iris-virginica   1.0  0.00000  1.0  1.0  1.0  1.0  1.0  \n",
       "\n",
       "[3 rows x 48 columns]"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.groupby(\"class\").describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>class</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>petal width</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0.1</th>\n",
       "      <td>[Iris-setosa]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0.2</th>\n",
       "      <td>[Iris-setosa]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0.3</th>\n",
       "      <td>[Iris-setosa]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0.4</th>\n",
       "      <td>[Iris-setosa]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0.5</th>\n",
       "      <td>[Iris-setosa]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0.6</th>\n",
       "      <td>[Iris-setosa]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1.0</th>\n",
       "      <td>[Iris-versicolor]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1.1</th>\n",
       "      <td>[Iris-versicolor]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1.2</th>\n",
       "      <td>[Iris-versicolor]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1.3</th>\n",
       "      <td>[Iris-versicolor]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1.4</th>\n",
       "      <td>[Iris-versicolor, Iris-virginica]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1.5</th>\n",
       "      <td>[Iris-versicolor, Iris-virginica]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1.6</th>\n",
       "      <td>[Iris-versicolor, Iris-virginica]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1.7</th>\n",
       "      <td>[Iris-versicolor, Iris-virginica]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1.8</th>\n",
       "      <td>[Iris-versicolor, Iris-virginica]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1.9</th>\n",
       "      <td>[Iris-virginica]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2.0</th>\n",
       "      <td>[Iris-virginica]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2.1</th>\n",
       "      <td>[Iris-virginica]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2.2</th>\n",
       "      <td>[Iris-virginica]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2.3</th>\n",
       "      <td>[Iris-virginica]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2.4</th>\n",
       "      <td>[Iris-virginica]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2.5</th>\n",
       "      <td>[Iris-virginica]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                         class\n",
       "petal width                                   \n",
       "0.1                              [Iris-setosa]\n",
       "0.2                              [Iris-setosa]\n",
       "0.3                              [Iris-setosa]\n",
       "0.4                              [Iris-setosa]\n",
       "0.5                              [Iris-setosa]\n",
       "0.6                              [Iris-setosa]\n",
       "1.0                          [Iris-versicolor]\n",
       "1.1                          [Iris-versicolor]\n",
       "1.2                          [Iris-versicolor]\n",
       "1.3                          [Iris-versicolor]\n",
       "1.4          [Iris-versicolor, Iris-virginica]\n",
       "1.5          [Iris-versicolor, Iris-virginica]\n",
       "1.6          [Iris-versicolor, Iris-virginica]\n",
       "1.7          [Iris-versicolor, Iris-virginica]\n",
       "1.8          [Iris-versicolor, Iris-virginica]\n",
       "1.9                           [Iris-virginica]\n",
       "2.0                           [Iris-virginica]\n",
       "2.1                           [Iris-virginica]\n",
       "2.2                           [Iris-virginica]\n",
       "2.3                           [Iris-virginica]\n",
       "2.4                           [Iris-virginica]\n",
       "2.5                           [Iris-virginica]"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.groupby(\"petal width\")[\"class\"].unique().to_frame()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/changfeng/anaconda3/envs/venv-py35/lib/python3.5/site-packages/ipykernel_launcher.py:1: FutureWarning: using a dict on a Series for aggregation\n",
      "is deprecated and will be removed in a future version\n",
      "  \"\"\"Entry point for launching an IPython kernel.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>min</th>\n",
       "      <th>delta</th>\n",
       "      <th>max</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>class</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Iris-setosa</th>\n",
       "      <td>0.1</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Iris-versicolor</th>\n",
       "      <td>1.0</td>\n",
       "      <td>0.8</td>\n",
       "      <td>1.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Iris-virginica</th>\n",
       "      <td>1.4</td>\n",
       "      <td>1.1</td>\n",
       "      <td>2.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                 min  delta  max\n",
       "class                           \n",
       "Iris-setosa      0.1    0.5  0.6\n",
       "Iris-versicolor  1.0    0.8  1.8\n",
       "Iris-virginica   1.4    1.1  2.5"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.groupby(\"class\")[\"petal width\"].agg({\"delta\": lambda x: x.max() - x.min(), \"max\": np.max, \"min\": np.min})"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# References"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* [http://pandas.pydata.org/pandas-docs/ stable/](http://pandas.pydata.org/pandas-docs/ stable/)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
